package org.guanmi.btc.browser.web;

import java.util.List;

import org.guanmi.btc.browser.common.ServiceResult;
import org.guanmi.btc.browser.contants.BtcBrowserCodeConstant;
import org.guanmi.btc.browser.domain.entity.User;
import org.guanmi.btc.browser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@RequestMapping("/user")
@Controller
public class UserController  {

    @Autowired
	UserService userService;
    @ResponseBody
	@RequestMapping(value = "/list", method = RequestMethod.POST)
	public ServiceResult<List<User>> list() {
    	ServiceResult<List<User>> result = new ServiceResult<List<User>>();
		try {
			result.setResult(userService.findAll());
			return result;
		} catch (Exception e) {
			result.setCode(BtcBrowserCodeConstant.SYSTEM_ERROR.getCode());
			result.setMessage(BtcBrowserCodeConstant.SYSTEM_ERROR.getMsg());
			return result;
		}
	}
 
}
